<?php

defined('SYSPATH') or die('No direct script access.');

abstract class Controller_Abstract_Layout extends Controller_Template {

    /**
     * Auto loading configs groups
     *
     * @var array
     */
    public $config_groups = array(
        'gallery',
    );

    /**
     * Auto loaded configs
     *     Format:
     *         array (group => params)
     *
     * @var array
     */
    public $config = array();

    /**
     * Default layout template
     *
     * @var View
     */
    public $template = 'layout';

    public function before() {
        parent::before();

        // load config
        foreach ($this->config_groups as $group)
        {
            $this->config[$group] = Kohana::$config->load($group)->as_array();
        }

        // bind this value as global for all templates
        View::set_global('galleryDir', rtrim($this->config['gallery']['uploadDir'], '/') . '/');
        View::set_global('config', $this->config);
    }

}